#define  _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>
#include <string.h>
int hex(char a[], int sz)
{
	int i = 0;
	int sum = 0;
	int base = 1;
	for (i = sz - 1; i >= 0; i--)
	{
		if (a[i] >= 'A' && a[i] <= 'F')
			sum += (a[i] - 'A' + 10) * base;
		else if (a[i] >= '0' && a[i] < '9')
		{
			sum += (a[i] - '0') * base;

		}
		base *= 16;
	}
	return sum;
}
int main()
{
	char a[] = "0";
	scanf("%s", a);

	int sz = strlen(a);
	hex(a, sz);
	printf("%d", hex(a, sz));
}